#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, INF = 0x3f3f3f3f;

string s;

int main()
{
    cin >> s;
    int hash[26] = { 0 };
    for(int i = 0;i < 26;i ++) hash[i] = 1;
    int k = 26, l = 0, r = 0, n = s.size(), len = INF;
    while(r < n)
    {
        if(-- hash[s[r] - 'a'] == 0) k --;
        while(k == 0)
        {
            len = min(len, r - l + 1);
            if(++ hash[s[l ++] - 'a'] == 1) k ++;
        }
        r ++;
    }
    cout << len << endl;
    return 0;
}